{extends file="index.tpl"}
{*block name="title" prepend}{$LNG.menu_index}{/block*}
{block name="content"}

<script type="text/javascript">{literal}
    $(document).ready(function() {
        reg_continiun = function(){
            $('#ststus_reg').html('<div class="myWinLoadS"></div>');

            $.ajax({
                url: 'index.php?page=reg&action=send',             // указываем URL и
                type: 'POST',
                data: $('#reg').serialize(),
                dataType : "json",                     // тип загружаемых данных
                success: function (data, textStatus) { // вешаем свой обработчик на функцию success
                    if(data.redirect)
                    {
                        $('#ststus_reg').html('<div align="left" style="padding:5px;"><div class="myWinLoadSD"></div></div>');
                        setTimeout("window.location.href='"+data.redirect+"'",2000);
                    }
                    $('#reg_container').html();
                    if(!data.error)
                    {
                        $('#ststus_reg').html('<div align="left" style="padding:5px;"><div class="myWinLoadSD"></div></div>');
                        //setTimeout("window.location.href='"+data.redirect+"'",2000);
                    }
                    else
                    {
                        $('#ststus_reg').html('<div align="left" style="padding:5px;"><div class="myWinLoadSF"></div></div>');
                        //setTimeout("$('#error_div').css({display:'none'});",1000); <div class="alert alert-error"></div>
                        $.each(data.message, function(i, val) {    // обрабатываем полученные данные
                            $('#reg_container').append('<div class="alert alert-error">'+val[1]+'</div>');
                        });


                    }
                }
            });
        }
    });


</script>{/literal}
	<table class="regbox" align="left">
		<tr class="contentbox-header">
			<td class="contentbox-header-left"></td><td class="contentbox-header-center"></td><td class="contentbox-header-right"></td>
		</tr>
		<tr class="contentbox-content">
			<td class="contentbox-content-left"></td><td id="reg_container" class="contentbox-content-center">
            	<img src="/logo.png" style=" margin-top:0; height:100px; margin-top:-50px;" />
                <br />
               	<h1>{$register}</h1>
					<form id="reg" name="reg" action="index.php?page=reg&action=send" method="post" onsubmit="reg_continiun(); return false;">
                    	<table>
              				{if $fb_active}<tr><td><input type="hidden" name="fb_id" id="fb_id"></td></tr>{/if}

                            <tr>
                            	<td class="left"><label class="bolder" for="reg_username">{$user}</label></td>
                                <td class="right"><input class="input_text" name="username" id="reg_username" type="text"></td>
                            </tr>
                            <tr>
                            	<td class="left"><label class="bolder" for="reg_password">{$pass}</label></td>
                                <td class="right"><input class="input_text" name="password" id="reg_password" type="password"></td>
                            </tr>
                            <tr>
                            	<td class="left"><label class="bolder" for="reg_password_2">{$pass_2}</label></td>
                                <td class="right"><input class="input_text" name="password_2" id="reg_password_2" type="password"></td>
                            </tr>
                            <tr>
                            	<td class="left"><label class="bolder" for="reg_email">{$email}</label></td>
                                <td class="right"><input class="input_text" name="email" id="reg_email" type="text"></td>
                            </tr>
                            <tr>
								<td class="left"><label class="bolder" for="reg_email_2">{$email_2}</label></td>
                                <td class="right"><input class="input_text" name="email_2" id="reg_email_2" type="text"></td>
                            </tr>
                            <tr>
								<td class="left"><label class="bolder" for="reg_planet">{$planetname}</label></td>
                                <td class="right"><input class="input_text" name="planetname" id="reg_planet" type="text"></td>
                            </tr>
                            <tr style="display:none;">
                                <td class="right"><select name="lang" id="reg_lang"><option value="ru"></option></select></td>
                            </tr>
						{if $game_captcha}
                        	<tr>
                        		<td class="left"><div id="recaptcha_image"></div></td>
								<td class="right"><label class="bolder" for="recaptcha_response_field">{$captcha_reg}</label><input class="input_text" type="text" id="recaptcha_response_field" name="recaptcha_response_field"></td>
                            </tr>{/if}
                            <tr>
                             	<td colspan="2" align="center">
                                     <table border="0" cellpadding="0">
                                         <tr>
                                             <td><button class="btn btn-mini" name="submit">{$LNG.register_login}</button></td>
                                             <td><div id="ststus_reg"></div></td>
                                         </tr>
                                     </table>
                                </td>
                            </tr>
                        	<tr>
                             	<td colspan="2" style="text-align:center"><label for="reg_rgt">{$accept_terms_cond}</label><input id="reg_rgt" name="rgt" type="checkbox" checked="checked"></td>
                            </tr>
                        </table>
                        {if $fb_active}<a href="javascript:FBlogin();" class="fb_login"><img src="http://b.static.ak.fbcdn.net/rsrc.php/zB6N8/hash/4li2k73z.gif" alt=""></a>{/if}
					</form>
			</td><td class="contentbox-content-right"></td>
		</tr>
		<tr class="contentbox-footer">
			<td class="contentbox-footer-left"></td><td class="contentbox-footer-center"></td><td class="contentbox-footer-right"></td>
		</tr>
	</table>
{/block}